import { useEffect } from 'react';
import { useRouter } from 'next/router';

const IndexPage: React.FC = () => {
    const router = useRouter();

    useEffect(() => {
        const token = localStorage.getItem('token');
        const permission = localStorage.getItem('permission');

        if (!token) {
            router.push('/login');
        } else {
            if (permission === 'asker') {
                router.push('/askerdashboard');
            } else if (permission === 'replyer') {
                router.push('/replyerdashboard');
            }
        }
    }, [router]);

    return null; // 或者返回一个加载中的提示
};

export default IndexPage;
